package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.api.R;
import com.itheima.reggie.common.ResultInfo;
import com.itheima.reggie.domain.Dish;
import com.itheima.reggie.domain.Setmeal;
import com.itheima.reggie.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    // 套餐列表
    @Cacheable(value = "setmeal", key = "#categoryId")
    @GetMapping("/setmeal/list")
    public ResultInfo lsit(Long categoryId, Integer status) {

        List<Setmeal> list = setmealService.findAll(categoryId, status);
        return ResultInfo.success(list);
    }

    //查询回显
    @GetMapping("/setmeal/dish/{id}")
    public ResultInfo selectById(@PathVariable Long id) {
        List<Dish> lsit = setmealService.selectById(id);
        return ResultInfo.success(lsit);
    }
}
